package org.github.xhjcehust.dubbo.proxy.gateway;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DubboInterceptor implements HandlerInterceptor {

    private Logger logger = LoggerFactory.getLogger(DubboInterceptor.class);

    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
        String path = httpServletRequest.getServletPath();
        logger.info("DubboInterceptor.preHandle："+path);
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
        String path = httpServletRequest.getServletPath();
        logger.info("DubboInterceptor.postHandle："+path);
    }

    @Override
    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
        String path = httpServletRequest.getServletPath();
        logger.info("DubboInterceptor.afterCompletion："+path);
    }
}
